A computer system may copy data from a storage device into a cache memory. The computer system may reduce storage access times by servicing storage access requests from the faster cache memory. When the cache fills up, the computer system may invalidate some data from the cache memory and repopulate the cache memory with other data from the slower storage device.
The computer system may use different criteria for replacing data in the cache memory. For example, the computer system may use a least recently used (LRU) scheme that replaces data in least recently accessed cache lines with data recently accessed data from the storage device. In another example, the computer system may use a least frequently used (LFU) scheme that replaces data in the cache lines with the fewest number of accesses with the data recently accessed from the storage device. Some memory systems may use a combination of the LRU scheme and the LFU scheme. Derivative systems (such as ARC) have also been used to improve the effectiveness of caching in storage systems and provide resiliency against storage access patterns that cause undesirable replacement of data (thrashing of the cache).
The LRU scheme and/or the LFU scheme still may not provide the most efficient and/or effective replacement of data in the cache. For example, a first set of data may be invalidated in the cache while a second set of data in the cache remains valid. The computer system then may request the first set of data while the second set of data remains unused in the cache. The computer system may experience slower memory access times since the first set of data now has to be accessed from the slower storage device. Caching systems may track storage access patterns and predict which data will be accessed in the future and for how long that data will be relevant. However, tracking and predicting storage operations is computationally intensive and sometimes may not be possible. The ability to determine whether data should be cached and for how long is a desirable capability within a storage system.